Release 10.1A: OpenEdge Data Management:
SQL Reference
Array data types
The
ARRAYdata type is a composite data value that consists of zero or more elements of a specified data type (known as the element type).VARARRAYdata type allows its element values to exceed the declared size when the total size is limited by SQL width.
data_typeThe data type of the array. This is also known as the element type.
Supported data types are:
BINARY, BIT, CHAR, VARCHAR, DATE, DECIMAL, DOUBLE PRECISION, FLOAT, INTEGER, NUMERIC, REAL, SMALLINT, TIME, TIMESTAMP, TIMESTAMP_TZ, TINYINT,andVARBINARY.[int]An unsigned integer, indicating the array’s maximum element size.
ExampleIn this example, table TBL is created. TBL has two columns: column C1 is an array of up to 3 elements, all of them type
intand column C2 is a variable-sized array of up to 4 elements, all of them typevarchar:
The size of any element in C2 can be up to 20 characters (5*4) with a total size of 20 characters.
Notes
ARRAY element reference
An element reference allows you to access a specific element of an array. It operates on two arguments: the first must evaluate to an array and the second must evaluate to an integer. The integer refers to the ordinal position of the element in the array (the first element in the array is element number one, the second is element number two, and so on).
ExampleIn this example, the fourth element of the array column named
array_columnis returned:
Default value for ARRAY columns
When creating array columns, you can specify a default value.
ExampleThe result returned from this example would be
10;10;10. Since no value is specified for array columnC2when inserting values, the default value is used:
Note: The default value is applicable only at the column level. This means that if fewer values are specified when executing an insert statement, the default will not be used to fill up the rest of the array elements. Instead,
NULLis used.Assignment
When an array is assigned to an array target, the assignment is done one element at a time. Two arrays are assignable if their element’s data types are mutually assignable. This means:
Example
- When an array is taken from SQL data to be assigned to an array target, if the number of elements in the source array equals the maximum number of elements in the target array, the assignment is straightforward. The value of each element of the source is assigned to the corresponding element of the target.
- If the maximum number of elements in the target array is less than the number of elements in the source array, then an error is returned.
- If the maximum number of elements in the target array is greater than the number of elements in the source array, the assignment of each of the source element values to the target elements occurs and the rest of the target elements will be assigned values of
NULL.
Comparison
OpenEdge SQL provides two scalar comparison operators: = and <>. Two arrays are comparable if their element data types are mutually comparable. During comparison, the elements are compared pair-wise in element order. Two arrays are equal if:
Two arrays are not equal if:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |